#include <cstdio>

struct Point3D
{
	int x;
	int y;
	int z;
};

int main(int argc, char* argv[])
{
	Point3D *pPoint1 = NULL;
	Point3D *pPoint2 = new Point3D;
	int offset1 = (int)(&pPoint1->z); //operator priority: '->' > '&'.
	int offset2 = (int)(&pPoint2->z);
	
	printf("pPoint1 = %d, offset1 = %d, pPoint2 = %d, offset2 = %d\n", (int)pPoint1, offset1, (int)pPoint2, offset2);

	delete pPoint1;
	delete pPoint2;
	return 0;
}

/*答案：输出8。由于在pPoint->z的前面加上了取地址符号，运行到此时的时候，会在pPoint的指针地址上加z在类型Point3D中的偏移量8。由于pPoint的地址是0，因此最终offset的值是8。

&(pPoint->z)的语意是求pPoint中变量z的地址（pPoint的地址0加z的偏移量8），并不需要访问pPoint指向的内存。只要不访问非法的内存，程序就不会出错。*/
